﻿#include "page_clean.h"
#include "ui_page_clean.h"

page_clean::page_clean(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::page_clean)
{
    //ui->setupUi(this);
    connect( this, SIGNAL( appendToLog(const QString &) ),parent, SLOT( appendToLog(const QString &) ) );
}

page_clean::~page_clean()
{
    delete ui;
}


void page_clean::show_Rad(std::vector<double> &v)
{
    if(v.size()==0)
        return;
    QString line1 = "<td>Xi</td>";
    QString line2 = "<td width=\"25\">Pi</td>";
    for(size_t i=0;i<v.size();++i)
    {
        line1+= QString("<td>%1</td>").arg(QString::number(i));
        line2+= QString("<td width=\"75\">%1</td>").arg(QString::number(v[i]));
    }
    emit appendToLog(QString("<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><tr>%1</tr><tr>%2</tr></table>").arg(line1).arg(line2));
}

void page_clean::show_Graph(std::vector<double> &v)
{
    double f=0;
	QString res = "<pre>F(X) =          0,\tX &#8712; (-&#8734;,0]\n";
    for(unsigned int i=0;i<v.size();++i)
    {
        f += v[i];
		res += QString("F(X) = %1,\tX &#8712; (%2,%3\n").arg(f,10).arg(i).arg( (i<v.size()-1) ? QString::number(i+1)+']' : "+&#8734;)" );
    }
    res += QString("</pre>");
    emit appendToLog(res);
}

/*void page_clean::on_calc_btn_clicked()
{
    if(ui->checkBox_rad_raspr->checkState()==Qt::Checked)     calc_Rad();
    if(ui->checkBox_math_o->checkState()==Qt::Checked)        calc_M();
    if(ui->checkBox_sr_kv_otkl->checkState()==Qt::Checked)    calc_S();
    if(ui->checkBox_disp->checkState()==Qt::Checked)          calc_D();
    if(ui->checkBox_f_raspr->checkState()==Qt::Checked)       calc_F();
    if(ui->checkBox_mng->checkState()==Qt::Checked)           calc_Mng();
    if(ui->checkBox_graph->checkState()==Qt::Checked)         calc_Graph();
    emit appendToLog(QString("1"));
}*/
